package com.ruoyi.nexus.controller;

import java.util.List;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nexus.domain.NexusHome;
import com.ruoyi.nexus.service.INexusHomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 源力星球页面Controller
 *
 * @author Afanda
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/NexusSphere/nexusHome")
public class NexusHomeController extends BaseController {
    @Autowired
    private INexusHomeService nexusHomeService;

    /**
     * 查询源力星球页面列表
     */
    @PreAuthorize("@ss.hasPermi('NexusSphere:nexusHome:list')")
    @GetMapping("/list")
    public TableDataInfo list(NexusHome nexusHome) {
        startPage();
        List<NexusHome> list = nexusHomeService.selectNexusHomeList(nexusHome);
        return getDataTable(list);
    }


    /**
     *  获取所有的分类名称
     * */


    /**
     * 导出源力星球页面列表
     */
    @PreAuthorize("@ss.hasPermi('NexusSphere:nexusHome:export')")
    @Log(title = "源力星球页面", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NexusHome nexusHome) {
        List<NexusHome> list = nexusHomeService.selectNexusHomeList(nexusHome);
        ExcelUtil<NexusHome> util = new ExcelUtil<NexusHome>(NexusHome.class);
        util.exportExcel(response, list, "源力星球页面数据");
    }

    /**
     * 获取源力星球页面详细信息
     */
    @PreAuthorize("@ss.hasPermi('NexusSphere:nexusHome:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(nexusHomeService.selectNexusHomeById(id));
    }

    /**
     * 新增源力星球页面
     */
    @PreAuthorize("@ss.hasPermi('NexusSphere:nexusHome:add')")
    @Log(title = "源力星球页面", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NexusHome nexusHome) {
        return toAjax(nexusHomeService.insertNexusHome(nexusHome));
    }

    /**
     * 修改源力星球页面
     */
    @PreAuthorize("@ss.hasPermi('NexusSphere:nexusHome:edit')")
    @Log(title = "源力星球页面", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NexusHome nexusHome) {
        return toAjax(nexusHomeService.updateNexusHome(nexusHome));
    }


    /**
     * 删除源力星球页面
     */
    @PreAuthorize("@ss.hasPermi('NexusSphere:nexusHome:remove')")
    @Log(title = "源力星球页面", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(nexusHomeService.deleteNexusHomeByIds(ids));
    }


    /**
     * 获取所有分类名称
     */
    @GetMapping("/nexus/list")
    public AjaxResult getNexusName() {
        List<NexusHome> list = nexusHomeService.getNexusName();
        return AjaxResult.success(list);
    }

}
